import 'package:guochaoapp/model/version_entity.dart';

versionEntityFromJson(VersionEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new VersionData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> versionEntityToJson(VersionEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

versionDataFromJson(VersionData data, Map<String, dynamic> json) {
	if (json['lastVersion'] != null) {
		data.lastVersion = json['lastVersion'].toString();
	}
	if (json['lastAvailable'] != null) {
		data.lastAvailable = json['lastAvailable'];
	}
	if (json['presentVersion'] != null) {
		data.presentVersion = json['presentVersion'].toString();
	}
	return data;
}

Map<String, dynamic> versionDataToJson(VersionData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['lastVersion'] = entity.lastVersion;
	data['lastAvailable'] = entity.lastAvailable;
	data['presentVersion'] = entity.presentVersion;
	return data;
}